package com.goldcn.sys.model.util;

import com.google.common.base.Objects;

/**
 * Created by Administrator on 2016/11/10.
 */
public enum RoleDataEnum {

    //特殊节点
    DATA(0,"dataPer","数据权限",""),STORE(1,"storePer","仓库权限",DATA.id),SHOP(2,"shopPer","门店权限",DATA.id);

    public final static Integer len = 3;
    private Integer seq;
    private String id;
    private String text;
    private String pid;

    RoleDataEnum(Integer seq,String id, String text, String pid) {
        this.seq = seq;
        this.id = id;
        this.text = text;
        this.pid = pid;
    }

    public Integer getSeq() {
        return seq;
    }

    public void setSeq(Integer seq) {
        this.seq = seq;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public static RoleDataEnum valuekOf(Integer index) {
        for (RoleDataEnum state : values()) {
            if (state.getSeq() == index) {
                return state;
            }
        }
        return null;
    }


    //类型
    public static enum Type{
      storePer,shopPer
    }

    public static int getType(Type type){
        switch(type){
            case storePer://仓库权限
                return 1;
            case shopPer://门店权限
                return 2;
        }
        return 1;
    }

    public static int getType(String pid){
        if(Objects.equal(pid,STORE.getId())){
            return getType(Type.storePer);
        }
        return getType(Type.shopPer);//门店的pid为区域的code
    }

}
